Repository navigation
release-binaries: give linux-x86_64-pgo a profile trained on Ocarina of Time - #1909
danieljesus wants to merge 17 commits into
Conversation
…of Time The Linux PGO builds use eglantine.profdata, which predates most of the Switch 2 code. Add lichii-linux.profdata, that profile (weight 1) merged with two sessions of Ocarina of Time gameplay on x86_64 (weight 12), trained on nx2 b9be325 with clang 23 as the job builds, and use it for linux-x86_64-pgo. linux-aarch64-pgo keeps eglantine.profdata, since no aarch64 profile has been measured. Steam Deck OLED, nx2 b9be325 built with the job's flags, old profile vs new, 3 interleaved rounds, standing / panning fps in Kokiri Forest with Max Resolution: Low 20.36 / 15.97 -> 21.21 / 17.09 (+4.2 % / +7.0 %), High 17.96 / 14.45 -> 18.47 / 15.48 (+2.8 % / +7.1 %). docs/CI.md gets a Linux section with the retraining steps. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RcHkcx3CbFgcY6d7BpdyKC
Walkthrough
Pre-merge checks:
|
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RcHkcx3CbFgcY6d7BpdyKC
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RcHkcx3CbFgcY6d7BpdyKC
The x86-64 Linux PGO packages compiled against eglantine.profdata, which was trained on another game. They now compile against lichii-linux.profdata: eglantine.profdata merged with a profile of Ocarina of Time played on x86-64 Linux, weighted to twice Eglantine's total count, the share Ocarina has in upstream's pull request zortos293#1909. linux-aarch64-pgo keeps eglantine.profdata. The session behind it is about 66,700 frames of scripted play through the debug server, in two rounds of nine starts: a new game's opening, Link's house with a menu save, Kokiri Forest, Hyrule Field, Castle Town, the Bazaar, the Deku Tree's first room and its chest, Dodongo's Cavern and Zora's Domain. Each start began with the title's pipeline cache empty. Every start recompiles the cached pipelines, and with a full cache the shader compiler took 49% of the counts; it holds 2.6% here. The first round overlaps the whole session by 98.1%. The static functions' source paths were rewritten to /home/runner/work/Lichii/Lichii, where this workflow compiles, so they match in the release. The static functions in eglantine.profdata and zortos293#1909's profile carry their trainers' paths, so none of them match there. The profile is trained on this source. A profile of the same session trained 16 upstream commits earlier, at upstream's 7088f67, had lost 10.3% of its counts by this source: 275 of the 20,131 functions it counted had changed, and 77 were gone. That earlier profile was measured on a Ryzen 7 8845HS with a Radeon 780M at 1x, on its own source built with clang 23.1.6 the way linux-x86_64-pgo builds it: the game's processor time per presented frame over the same scripted scene, median of three runs per build and scene. The file committed here has not been measured. Scene No profile eglantine zortos293#1909 That profile Kokiri Forest 117.1 ms -1.0% -3.1% -3.7% Kakariko Village 111.2 ms -0.5% +2.9% -2.4% Goron City 99.8 ms -0.7% -1.6% -3.7% The session never visits Kakariko Village or Goron City. Every run with that profile used less processor time than every run without a profile, in all three scenes. Against zortos293#1909's profile its medians are lower in all three, but the runs overlap in Kokiri Forest and Goron City, and in Kakariko Village the runs with zortos293#1909's profile spread 6.7%. The GPU was 92 to 94% busy, so the frame rate moved 1 to 2.5%. -march=znver4 on top of that profile made no measurable difference.
…ntly of the checkout path linux-x86_64-pgo now uses lichii-linux.profdata: eglantine.profdata, weight 1, merged with two sessions of Ocarina of Time gameplay on x86-64 Linux, weight 12. A profile names a file-local function by its source file's path, so a profile trained in one checkout matched nothing of those functions on the runner. The job and the training build now both pass -mllvm -static-func-strip-dirname-prefix with the depth of the source root, which makes those names start at src/. The job also passes -mllvm -pgo-warn-missing-function; the summary counts those missing-profile warnings and warns past PGO_MISSING_MAX (3000). A matrix entry with pgo but no profile is now an error instead of falling back to eglantine.profdata; both PGO entries set one. On a Steam Deck OLED (Ocarina of Time, Kokiri Forest route), the tip built with this profile against the tip as the job builds it today with eglantine.profdata, both built in a checkout other than the one the profile was trained in: +6.6 % fps standing, +8.1 % panning (4 alternating pairs each). Missing-profile warnings drop from 31,799 to 1,132, functions whose code changed since training from 2,191 to 4. docs/CI.md describes the flags, the counts and how to retrain. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RcHkcx3CbFgcY6d7BpdyKC Claude-Session: https://claude.ai/code/session_01RcHkcxSN7aBbebPQ17pqcF
…to perf/linux-pgo-profile The conflict with nx2 was in release-binaries.yml; the result is the tree of the retrained change, which replaces this branch's earlier profile, workflow and docs. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RcHkcxSN7aBbebPQ17pqcF
|
Updated on top of current nx2 (the conflict was in While checking the profile against a build made the way the runner makes it, we found that a profile names file-local functions by their source file's path, so a profile trained in one checkout matches none of them in another: about a seventh of the functions got no data, with no warning. The first version of this PR had that problem, and so does 🤖 Generated with Claude Code |
…file was trained with lichii-linux.profdata was trained with GCC 13's libstdc++ headers (Ubuntu 24.04's default). The hosted ubuntu-24.04 image also carries GCC 14, and clang compiles against the newest GCC it finds. A profile hashes each function's control flow with the std:: code inlined into it, so a build against GCC 14's headers matches none of the functions that inline code from those headers. A fork's release build with this job and this kind of profile showed it: its Linux PGO package lost the profile data of 308 functions with counts, 63 of them non-template code (the renderer's state updates, the macro engine, the shader translator). 1,036 of its hash mismatches were for std::vector::_M_realloc_append, which libstdc++ has only from GCC 14 on. The Linux PGO entry now: - passes --gcc-install-dir for GCC 13 (PGO_GCC_MAJOR) when compiling and, through CMAKE_CXX_FLAGS, when linking; - fails early in its clang install step if that GCC's headers are missing, so that a later image cannot fall back silently; - warns if the installed clang is not PGO_CLANG_BUILD, the build that trained the profile. apt.llvm.org keeps only the newest snapshot of each major, so an exact pin would fail the install once it moves. Every Linux entry prints the standard library it compiles against. docs/CI.md says what training and the job must agree on (the clang build, the standard library headers and the configuration) and how each is held. It also gains the rule this came from: a measurement that backs a profile is taken on a binary built exactly as the job builds it. Checked on a Steam Deck with the fork's profile of the same kind (the job's PGO flags, --gcc-install-dir for GCC 13, a checkout other than the training one): "Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/13", and 4 hash mismatches, none with counts. This PR's own run is what shows two things: that clang selects 13 with 14 present on the hosted image, and the counts for this PR's profile (the printed toolchain and the PGO summary). actionlint passes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RcHkcxAKTuSh2fpgFJdwbE Claude-Session: https://claude.ai/code/session_01RcHkcxSN7aBbebPQ17pqcF
The profile was trained on a tree 20 upstream commits older. Applied to this one with the job's flags, it had lost its data for 12 functions that training had reached, among them the shader compiler's SSA rewrite pass and the Vulkan fence manager's release thread, and the missing-profile warnings had grown from 1,132 to 1,311. lichii-linux.profdata is retrained on this tree with the toolchain the job now pins: an Ubuntu 24.04 container with clang 23.1.6~++20261116013850+5b10d2d74929 (PGO_CLANG_BUILD) and GCC 13's standard library, the local function names keyed from src/. eglantine.profdata, with its author's checkout prefix stripped, weight 1, merged with two sessions of Ocarina of Time on a Steam Deck, weight 12. 21,523,104 bytes, sha256 86c4bd405fab9b08e2535279c53f84c3224c2643a4bf47eab2905a422c25c229. Applied from a checkout other than the training one with this tree's Linux PGO flags (and the comdat and weak mismatch warnings on, for the count), building lichii and lichii-cmd: 5 hash mismatches, the only one with counts lichii-cmd's main, whose name the lichii executable's main also has; none in src/ otherwise; 1,282 missing-profile warnings. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RcHkcx3CbFgcY6d7BpdyKC Claude-Session: https://claude.ai/code/session_01RcHkcxSN7aBbebPQ17pqcF
… summary did not show From review of this PR before it is published. The summary could not show the failure this PR is about: - hash mismatches raised no annotation; - those of template and inline functions were not counted at all; - a summary of zeros read as a perfect profile, though it is also what dropped warning flags give. So the PGO build now: - passes -mllvm -no-pgo-warn-mismatch-comdat-weak=false, so template and inline functions' mismatches are reported too. It changes only diagnostics. On the committed profile and this tree it adds no function with counts beyond lichii-cmd's main. - warns when more than PGO_MISMATCH_MAX (10) functions lost profile data that had counts (retrain); - warns when there are no missing-profile warnings at all: the flags that report them did not reach the build. The GCC pin is checked, not only printed: - the configure step stops the job unless clang reports the pinned GCC as its "Selected GCC installation"; - the GCC directory's triple comes from gcc -dumpmachine; - the clang-build warning names the matrix's profile. Comments and docs/CI.md corrected to what was measured: - the missing-profile count of the committed profile on its own tree is 1,282 (not "about 1,100"); the unsourced "about 13,800" is gone; - path-keyed names are about a fifth of the profile (14,763 of 78,301 records), not a seventh; - the retrain rule: 12 functions lost over 20 upstream commits, not "roughly five per commit", and the summary's count is the signal; - step 1 of the retrain recipe passes --gcc-install-dir; - the crt files and libgcc follow the pin, libstdc++.so.6 is the system's single copy either way; - the missing-headers check runs before configure fails on the flag; - eglantine.profdata was trained against libstdc++ 14 or later (it holds std::vector::_M_realloc_append records, which GCC 13's headers lack). With the job on 13, its records whose inlined library code differs no longer match. actionlint passes. Not run on a hosted runner: the workflow runs on dispatch, a push to nx2-experimental or its schedule. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RcHkcxAKTuSh2fpgFJdwbE Claude-Session: https://claude.ai/code/session_01RcHkcxSN7aBbebPQ17pqcF
…ary from failing a build
The mismatch warning counted log lines. A function that lost its data
in several translation units warns once per unit:
- the previous profile on this tree gave 13 lines for 12 functions;
- our fork's run 9 gave 787 lines for 308.
It now counts distinct function names. The name follows
"(hash mismatch) ", and mangled names hold no spaces. The summary's
two figures are counted the same way, and say so: functions whose
profile data was discarded, and of them those with nonzero counts.
The missing-profile count stays one per function and translation
unit, as its line now says.
The summary block now runs in a subshell whose failure is a warning
("the build itself succeeded"), so no command in it can fail a build
that has already finished, as in our fork's job. The lost count also
survives pipefail when nothing matches.
Checked on a sample log: a function with counts in two units, another
with counts, and one without counts give 3 discarded, 2 with nonzero
counts and lost = 2; an empty log gives 0. actionlint passes.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RcHkcxAKTuSh2fpgFJdwbE
Claude-Session: https://claude.ai/code/session_01RcHkcxSN7aBbebPQ17pqcF
|
A correction before this merges. The description said the profile was trained "in the job's own container image". The job builds on the hosted The profile was trained with GCC 13's libstdc++. Unpinned, the runner's clang picks GCC 14's. We hit exactly this on our fork's release run: its Linux PGO build lost the profile on 308 functions with counts, most visibly This push:
The description is corrected. The fps figures come from the profile as first trained, on the tree before this refresh, against 🤖 Generated with Claude Code |
|
The manual run, on our fork, of this branch's head (d2e96fa, That is the clang build the profile was trained with, and the pinned GCC; the gate passed. Its PGO figures, counted from the build log:
So on the runner the profile applies as it did where it was trained. Still not measured: fps of this artifact against a published build. 🤖 Generated with Claude Code |
|
The measurement the description listed as missing: this PR's artifact against a build made as the job builds nx2 today.
Steam Deck OLED, Ocarina of Time, Kokiri Forest, nothing instrumented, default power settings, same session, a warm-up each and then alternating runs:
Four runs of A and three of B (B's fourth did not reach the scene: the driver reported a device loss during boot, once in nine boots of B and none in nine of A; one event, so it says nothing by itself). A was ahead in every pair. Standing, every A run (21.94–22.47) is above every B run (20.98–21.11). So against what the job ships today the gain is +5.5 % and +6.2 %, a little under the +6.6 % and +8.1 % in the description's table, whose baseline was 🤖 Generated with Claude Code |
Brings the branch up to date with nx2 so that the PR's checks run against the current base. No conflicts; no other change. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RcHkcxSN7aBbebPQ17pqcF
Brings the branch up to date with nx2 so that the PR's checks run against the current base. No conflicts; no other change. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RcHkcxSN7aBbebPQ17pqcF
Brings the branch up to date with nx2 so that the PR's checks run against the current base. No conflicts; no other change. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RcHkcxSN7aBbebPQ17pqcF
Brings the branch up to date with nx2 so that the PR's checks run against the current base. No conflicts; no other change. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RcHkcxSN7aBbebPQ17pqcF
Brings the branch up to date with nx2 so that the PR's checks run against the current base. No conflicts; no other change. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RcHkcxSN7aBbebPQ17pqcF
Brings the branch up to date with nx2 so that the PR's checks run against the current base. No conflicts; no other change. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RcHkcxSN7aBbebPQ17pqcF
Brings the branch up to date with nx2 so that the PR's checks run against the current base. No conflicts; no other change. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RcHkcxSN7aBbebPQ17pqcF
Brings the branch up to date with nx2 so that the PR's checks run against the current base. No conflicts; no other change. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RcHkcxSN7aBbebPQ17pqcF
The Linux counterpart of #1884 (Windows).
What
The Linux PGO build compiles against
eglantine.profdata, which predates most of the Switch 2 code. This addslichii-linux.profdata: that same profile (weight 1, its author's checkout prefix stripped) merged with two sessions of Ocarina of Time gameplay on a Steam Deck (weight 12), trained on this PR's tree.linux-x86_64-pgonow uses it through the matrix'sprofilefield, which the Windows job already uses. Merging instead of replacing keeps Eglantine's records where they still match: they were trained against libstdc++ 14 or later (they includestd::vector::_M_realloc_append, which GCC 13's headers lack), so with the job pinned to GCC 13 those whose inlined library code differs no longer match and add nothing.What the profile was trained with: an Ubuntu 24.04 container with
PGO_LLVM_VERSION; the job now names it inPGO_CLANG_BUILDand warns when the installed one differs);src/.The hosted
ubuntu-24.04image carries GCC 12, 13 and 14, and clang picks the newest by default. So the job now pins GCC 13 for this entry:--gcc-install-dirto clang;Without the pin, a profile trained against one libstdc++ loses its counts on the functions whose inlined library code differs between the two headers. Our fork's release run showed it: built on this runner with this job and a profile of the same kind, without the pin, the PGO build lost the profile on 308 functions with counts. 63 of them are non-template code: the renderer's state updates (
UpdateVertexInput,UpdateDynamicStates,UpdateDepthBias, ...), the macro engine and the shader translator. Our fork's job also passes-mllvm -no-pgo-warn-mismatch-comdat-weak=false, so its log listed template functions too: 1,036 of its lines were forstd::vector::_M_realloc_append, which only GCC 14's headers have. That shows GCC 14's headers were in use; those records came from Eglantine's profile.It also fixes something that made any profile trained outside the runner lose part of its effect. A profile names a file-local function (static, or in an anonymous namespace) by the path of its source file, so a profile trained in one checkout matched none of those functions when the job built in another: about a fifth of the profile's functions (14,763 of 78,301 records) silently got no data. The job and the training build now both pass
-mllvm -static-func-strip-dirname-prefix=N, with N the depth of the source root, so those names start atsrc/and match in any checkout.eglantine.profdatahad the same problem with its author's path; the merge strips it (steps indocs/CI.md).So that this cannot go unnoticed again, the job passes
-mllvm -pgo-warn-missing-functionand-mllvm -no-pgo-warn-mismatch-comdat-weak=false(diagnostics only), the PGO summary counts missing-profile warnings and functions that lost data with counts, and it warns when the first passesPGO_MISSING_MAX(3000) or is 0 (the flags did not reach the build), and when the second passesPGO_MISMATCH_MAX(10). The configure step also stops the job unless clang reports the pinned GCC as the one it selected. A matrix entry withpgobut noprofileis now an error instead of falling back toeglantine.profdata; both PGO entries set one.docs/CI.mdgains the rule this came from: a platform's measurement must be of a binary built exactly as the job builds it, toolchain and standard library included.A profile ages with the tree. Applied to a tree 20 upstream commits newer than the one it was trained on, this profile lost its data for 12 of our functions that training had reached, among them the shader compiler's SSA rewrite pass and the Vulkan fence manager's release thread. On its own tree it lost none. So it is retrained on this PR's tree: applied from a checkout other than the training one with this tree's flags, 5 functions report changed code, the only one with counts being
lichii-cmd'smain(it shares its name with thelichiiexecutable'smain, which training reached). None of the others is insrc/, and there are 1,282 missing-profile warnings. The job's summary counts such functions (hash mismatches with counts), and that count, not the number of commits since training, is the signal to retrain.Files:
lichii-linux.profdata(21.5 MB, sha25686c4bd40…c229),.github/workflows/release-binaries.yml,docs/CI.md(the flags, the GCC pin, the counts, how to retrain, and the rule).Measurements
Steam Deck OLED (Zen 2, 4 cores, RADV), Ocarina of Time, Kokiri Forest route. Measured with the profile as first trained (the same recipe, on the tree 20 commits older), on that tree, against
eglantine.profdata:eglantine.profdatabuilt against GCC 13's headers, not the published build (which compiled against GCC 14's). Eglantine's profile was trained against libstdc++ 14 or later, so this baseline handicaps it, and the gain below may be larger than against the published build.Four alternating pairs:
eglantine.profdata, GCC 13On this PR's tree the retrained profile gives 1,282 missing-profile warnings and 5 changed functions (above).
The new build was ahead in all four pairs, standing and panning.
These were measured on our own builds, not on the job's artifact, and not against the published build: fps against the published artifact were not measured. The workflow runs only on dispatch, a push to
nx2-experimentalor its schedule, so the job's own artifact needs a manual run. Until that run, that the runner's clang selects GCC 13 is checked on a Steam Deck only; the run's log ("Selected GCC installation", now a gate) and its PGO summary (expected: 1,282 missing-profile warnings,lichii-cmd'smainthe only function with counts lost) are what confirm it there.The figures in this PR's first version (+4.2 % / +7.0 %) were measured in the checkout the profile had been trained in. On the runner the file-local functions would not have matched, so part of that gain would not have appeared there; the strip flag is what makes the measurement above hold in any checkout.
Not measured
Other games, other x86_64 CPUs, and aarch64. The profile is weighted towards the paths Ocarina of Time reaches, like the Windows one.
-static-func-strip-dirname-prefixis an internal LLVM option, verified with clang 23.1.6; if a later LLVM drops it the build fails on the unknown option rather than silently losing the match.Which GCC to pin is a choice. Pinning 13 matches Ubuntu 24.04's default and the container our profile was trained in; Eglantine's records whose inlined library code comes from libstdc++ 14 then match nothing. Pinning 14 (what the runner's clang picks by itself) would keep more of Eglantine's records alive (one reviewer count: 1,793 of its 15,850 records with counts, 33 % of its count mass, have a hash different from a GCC 13 build's), at the cost of retraining our profile on 14 (a container with gcc-14), with ours at weight 12 either way. This PR keeps 13; the pin is explicit whichever number is chosen.
The Windows entry has a counterpart of the path problem (its profile's keys carry the checkout path). That comes as a separate PR once this one is in, since it can only be checked on a run.
🤖 Generated with Claude Code
https://claude.ai/code/session_01RcHkcxSN7aBbebPQ17pqcF
Summary by CodeRabbit